/*
 *
 * Copyright (C) 2012 Walter Lütgenau
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package offset.nodes.client.vdialog.model.instance;

import javax.jcr.Node;
import offset.nodes.Constants;
import offset.nodes.client.virtual.model.jcr.SimpleNode;
import offset.nodes.client.virtual.model.jcr.HashNodeFactory;
import offset.nodes.client.virtual.model.jcr.NodeFactory;

/**
 *
 * @author Walter Lütgenau
 */
public class TemplateInstanceNodeFactory extends HashNodeFactory {
    public TemplateInstanceNodeFactory() {
        add(Constants.TYPE_TEMPLATE_INSTANCE, new NodeFactory() {

            public Node newNode() {
                SimpleNode node = new TemplateInstance(null);
                node.setProperty(Constants.JCR_PRIMARY_TYPE,Constants.TYPE_TEMPLATE_INSTANCE);
                node.setProperty(Constants.JCR_MIXIN_TYPES, Constants.JCR_VERSIONABLE);
                return node;
            }
            
        });
        
        add(Constants.TYPE_VIRTUAL_FOLDER_INSTANCE, new NodeFactory() {

            public Node newNode() {
                SimpleNode node = new VirtualFolderInstance();
                node.setProperty(Constants.JCR_PRIMARY_TYPE,Constants.TYPE_VIRTUAL_FOLDER_INSTANCE);
                node.setProperty(Constants.JCR_MIXIN_TYPES, Constants.JCR_VERSIONABLE);
                return node;
            }
            
        });
        
        add(Constants.TYPE_VIRTUAL_PAGE_INSTANCE, new NodeFactory() {

            public Node newNode() {
                SimpleNode node = new VirtualPageInstance();
                node.setProperty(Constants.JCR_PRIMARY_TYPE,Constants.TYPE_VIRTUAL_PAGE_INSTANCE);
                node.setProperty(Constants.JCR_MIXIN_TYPES, Constants.JCR_VERSIONABLE);
                return node;
            }
            
        });
    }
}
